//
//  CertAuthorityInfoAccess.m
//  TestProject
//
//  Created by 毕武侠 on 2022/2/20.
//  Copyright © 2022 zhulong. All rights reserved.
//

#import "CertAuthorityInfoAccess.h"

@implementation CertAuthorityInfoAccess

/*
 30 6F
    06 08 2B 06 01 05 05 07 01 01
    04 63
 
 30 61(97):
    30 28(40):
        06 08(08): 2B 06 01 05 05 07 30 01
        86 1C(28): 68 74 74 70 3A 2F 2F 6F 63 73 70 2E 63 66 63 61 2E 63 6F 6D 2E 63 6E 2F 6F 63 73 70
    30 35(53):
        06 08(08): 2B 06 01 05 05 07 30 02
        86 29(41): 68 74 74 70 3A 2F 2F 63 72 6C 2E 63 66 63 61 2E 63 6F 6D 2E 63 6E 2F 6F 63 61 33 33 2F 6F 63 61 33 33 73 6D 32 2E 63 65 72
 */

- (void)loadCertData {
    self.accessDescription = [self getList:self.data type:0x30];
}

- (id)getObject:(NSData *)data type:(uint16_t)type {
    if (type == 0x130) {
        return [[CertOID alloc] initWithData:data];
    }
    return nil;
}

- (NSString *)description {
    NSMutableString *str = [NSMutableString string];
    NSMutableString *accessDescriptions = [NSMutableString string];
    for (int i = 0; i < self.accessDescription.count; i++) {
        [accessDescriptions appendFormat:@"\t[%d]: %@(%@)=%@\n", i, self.accessDescription[i].oid, self.accessDescription[i].oidDesc, self.accessDescription[i].value];
    }
    if (accessDescriptions.length > 0) {
        [str appendFormat:@"[\n%@]", accessDescriptions];
        return str;
    }
    return @"无数据";
}

@end
